<?php


namespace EchoPHP\Database\TuxedoDriver;

use EchoPHP\Support\Str;
use Exception;
use \RuntimeException;

class TuxedoException extends RuntimeException {

    protected $sendBuffer;
    protected $receiveBuffer;
    protected $serverName;

    public function __construct($message, $code, $serverName, $sendBuffer = '', $receiveBuffer = '', Exception $previous = null) {
        parent::__construct($message, $code, $previous);

        $this->serverName = $serverName;
        $this->sendBuffer = Str::convertCharset($sendBuffer, 'UTF-8', 'GBK');
        $this->receiveBuffer = Str::convertCharset($receiveBuffer, 'UTF-8', 'GBK');
    }

    public function getBuffer() {
        return "serverName:[" . $this->serverName . "]sendBuffer:[" . $this->sendBuffer . "]" . ";receiveBuffer:[" . $this->receiveBuffer . "]";
    }

    public function getServerName() {
        return $this->serverName;
    }

    public function getSendBuffer() {
        return $this->sendBuffer;
    }

    public function getReceiveBuffer() {
        return $this->receiveBuffer;
    }
}